<template>
	<view class="content">
		<view class="card">
			<step v-model="index"></step>
		</view>
		<template v-if="index==1">
			<view class="card">
				<cell title='企业名称' v-model="formData.qymc" required></cell>
				<cell title='统一社会信用代码' v-model="formData.xydm" required></cell>
				<cell title='企业纳税人识别号' v-model="formData.nssbh" required></cell>
				<cell title='法定代表人姓名' v-model="formData.dbrxm" required></cell>
				<cell title='法定代表人身份证号' mode="input" v-model="formData.dbrCrad" required></cell>
				<cell title='业务办理地区(纳税地)' mode="region" v-model="formData.ywblcs" required></cell>
				<cell title='手机号' mode="input" v-model="formData.phoneNo" required></cell>
				<cell title='推荐人' v-model="formData.tjr"></cell>
			</view>
			<view class="text-tip">
				<view class="text-tip-title">温馨提示</view>
				<view class="">1.本产品为企业贷款，申请人应为企业法定代表人本人。</view>
			</view>
			<button class="btn" size="default" type="primary" @click="submit()" hover-class="is-hover">下一步</button>
		</template>
		<template v-if="index==2">
			<view class="card">
				<cell title='纳税信息认证授权' mode="jump" jumpUrl="/pages/common/uploadIDCard" :jumpBtn="['待认证','认证成功']"
					v-model="formData2.auth" required></cell>
				<cell title='信息录入' mode="jump" jumpUrl="/pages/enterprise/infoInput" :jumpBtn="['待录入','已录入']"
					jumpReIn="查看" v-model="formData2.infoInput" required></cell>
				<cell title='法定代表人身份认证' mode="jump" jumpUrl="/pages/common/faceIdentifySuccess" :jumpBtn="['待认证','已认证']"
					v-model="formData2.fdauth" required></cell>

				<template v-if="isMortageProperty">
					<cell title='房产信息录入' mode="jump" jumpUrl="/pages/enterprise/house/index" v-if="lr"
						:jumpBtn="['待录入','已录入']" jumpReIn="修改" v-model="formData2.fcInfoInput" required></cell>
					<cell title='房产信息录入' mode="jump" jumpUrl="/pages/enterprise/house/index" v-else
						:jumpBtn="['待录入','不录入']" jumpReIn="修改" v-model="formData2.fcInfoInput" required></cell>
				</template>
				<cell title='资料采集' mode="jump" jumpUrl="/pages/common/uploadIDCard" :jumpBtn="['待采集','已采集']"
					v-model="formData2.zlcjInfo" required></cell>
			</view>


			<ReadmeBtn :readme="['企业信用信息、及其他相关信息查询、使用和提供授权书','个人征信授权书']" text="提交申请" @submit="submit"></ReadmeBtn>
		</template>

		<view v-if="index==3" class="success-tip">
			<view class="card">
				<icon type="success" size="130" />
				<br>
				<view class="tip2">尊敬的客户，你已完成贷款。</view>
				<view class="tip2">我行经理将在3个工作日内与你取得联系，请您耐心等候。</view>
			</view>
			<button class="btn" size="default" type="primary" @click="backHome()" hover-class="is-hover">返回首页</button>
		</view>


	</view>
</template>
slot
<script>
	import step from "@/components/step.vue"
	export default {
		components: {
			step
		},
		data() {
			return {
				isMortageProperty:false,
				lr: true,
				index: 1,
				formData: {
					qymc: '成都XXX农业科技公司',
					xydm: 'D123******',
					nssbh: 'N123****',
					dbrxm: '张三',
					dbrCrad: '511018****',
					ywblcs: '',
					phoneNo: '136 **** ****',
					tjr: '',
					// qdbljg: '',
					// date:'',
					// time:''
				},
				formData2: {
					fdauth: '',
					auth: true,
					infoInput: true,
					fcInfoInput: '',
					zlcjInfo: ''
				}
			}
		},
		onLoad() {
			this.isMortageProperty = uni.getStorageSync('isMortageProperty')||false
		},
		onShow() {
			this.formData2.infoInput = uni.getStorageSync('infoInput')
			this.formData2.fdauth = uni.getStorageSync('fdauth')
			this.formData2.zlcjInfo = uni.getStorageSync('zlcjInfo')
			this.lr = uni.getStorageSync('fcInfoInput') === '已录入'
			this.formData2.fcInfoInput = uni.getStorageSync('fcInfoInput')
		},
		watch: {
			index() {
				if (this.index === 1) {
					this.readme = []
					this.btntext = '下一步'
					return
				}
				if (this.index === 2) {
					this.readme = ['企业信用信息及其他相关信息查询、使用和提供授权书', '个人征信授权书']
					this.btntext = '提交申请'
					return
				}

			}
		},
		methods: {
			backHome() {
				// uni.navigateBack({
				// 	delta: 10
				// })
				uni.redirectTo({
					url: '/pages/home'
				})
			},
			next() {
				this.index++
			},
			toast(title) {
				uni.showToast({
					icon: "none",
					title,
				})
			},
			async submit() {
				if (this.index === 1) {
					if (!this.formData.qymc) {
						this.toast('请填写企业名称')
						return
					}
					if (!this.formData.xydm) {
						this.toast('请填写统一社会信用代码')
						return
					}
					if (!this.formData.nssbh) {
						this.toast('请填写企业纳税人识别号')
						return
					}
					if (!this.formData.dbrxm) {
						this.toast('请填写法定代表人姓名')
						return
					}
					if (!this.formData.dbrCrad) {
						this.toast('请填写法定代表人身份证号')
						return
					}
					if (!this.formData.ywblcs) {
						this.toast('请填写业务办理地区')
						return
					}
					if (!this.formData.phoneNo) {
						this.toast('请填写手机号')
						return
					}
					await this.$myloading() // async
				} else if (this.index === 2) {
					if (!this.formData2.infoInput) {
						this.toast('请完成信息录入')
						return
					}
					if (!this.formData2.fdauth) {
						this.toast('请完成法定代表人身份认证')
						return
					}
					if (this.isMortageProperty&&!this.formData2.fcInfoInput) {
						this.toast('请完成房产信息录入')
						return
					}
					if (!this.formData2.zlcjInfo) {
						this.toast('请完成资料采集')
						return
					}
					await this.$myloading() // async
				}
				if (this.index < 3) {
					this.index++
				}
			}
		}
	}
</script>


<style lang="scss" scoped>
	.btn {
		margin-top: 60rpx;
		width: calc(100% - 60rpx);
	}
</style>